package com.xinli.business.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xinli.business.domain.TQuestionFollow;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinli.common.annotation.Log;
import com.xinli.common.core.controller.BaseController;
import com.xinli.common.core.domain.AjaxResult;
import com.xinli.common.enums.BusinessType;
import com.xinli.business.domain.LfPostFabulous;
import com.xinli.business.service.ILfPostFabulousService;
import com.xinli.common.utils.poi.ExcelUtil;
import com.xinli.common.core.page.TableDataInfo;

/**
 * 帖子收藏Controller
 *
 * @author ruoyi
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/business/fabulous")
public class LfPostFabulousController extends BaseController
{
    @Autowired
    private ILfPostFabulousService lfPostFabulousService;

    /**
     * 查询帖子收藏列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LfPostFabulous lfPostFabulous)
    {
        startPage();
        List<LfPostFabulous> list = lfPostFabulousService.selectLfPostFabulousList(lfPostFabulous);
        return getDataTable(list);
    }

    /**
     * 导出帖子收藏列表
     */
    @Log(title = "帖子收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LfPostFabulous lfPostFabulous)
    {
        List<LfPostFabulous> list = lfPostFabulousService.selectLfPostFabulousList(lfPostFabulous);
        ExcelUtil<LfPostFabulous> util = new ExcelUtil<LfPostFabulous>(LfPostFabulous.class);
        util.exportExcel(response, list, "帖子收藏数据");
    }

    /**
     * 获取帖子收藏详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lfPostFabulousService.selectLfPostFabulousById(id));
    }

    /**
     * 新增帖子收藏
     */
    @Log(title = "帖子收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LfPostFabulous lfPostFabulous)
    {
        return toAjax(lfPostFabulousService.save(lfPostFabulous));
    }

    /**
     * 修改帖子收藏
     */
    @Log(title = "帖子收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LfPostFabulous lfPostFabulous)
    {
        return toAjax(lfPostFabulousService.updateById(lfPostFabulous));
    }

    /**
     * 删除帖子收藏
     */
    @Log(title = "帖子收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lfPostFabulousService.removeByIds(Arrays.asList(ids)));
    }



}
